import type { PluginOption } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";

import createInspector from "./inspector";
import createAutoImport from "./auto-import";
import createComponents from "./components";
import createSetupExtend from "./setup-extend";
import createSvgIcon from "./svg-icon";
import createLayouts from "./layouts";
import createPages from "./pages";
import createCompression from "./compression";
import createSpritesmith from "./spritesmith";
import createHtmlPlugin from "./create-html-plugin";
import createUno from "./uno";

export default function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins: (PluginOption | PluginOption[])[] = [vue(), vueJsx()];
  vitePlugins.push(createInspector());
  vitePlugins.push(createAutoImport());
  vitePlugins.push(createComponents());
  vitePlugins.push(createSetupExtend());
  vitePlugins.push(createSvgIcon(isBuild));
  vitePlugins.push(createLayouts());
  vitePlugins.push(createPages());
  isBuild && vitePlugins.push(...createCompression(viteEnv));
  vitePlugins.push(...createSpritesmith(isBuild));
  vitePlugins.push(createHtmlPlugin(viteEnv));
  vitePlugins.push(createUno());
  return vitePlugins;
}
